<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>UDT Reference</title>
</head>

<body>

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="table1" bgcolor="#99CCFF" bordercolor="#99CCFF">
  <tr>
    <td width="100%"><font face="Verdana" size="2"><i>&nbsp;UDT Reference: UDT 
	Functions</i></font></td>
  </tr>
</table>
<h1><font size="4" face="Verdana">bind</font></h1>
<p><font face="Verdana" size="2">The <b>bind</b> method associates an socket 
with a local 
address.</font></p>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="AutoNumber2" bgcolor="#C0C0C0" bordercolor="#C0C0C0">
  <tr>
    <td width="100%">
    <p style="margin-top: 0; margin-bottom: 0">
    <font size="1" face="Courier New">int bind(<br>
&nbsp; UDTSOCKET <font color="#FFFFFF"> <a class="synParam" onclick="showTip(this)">u</a></font>,</font></p>
	<p style="margin-top: 0; margin-bottom: 0">
    <font size="1" face="Courier New">&nbsp; const struct sockaddr *<font color="#FFFFFF"><a class="synParam" onclick="showTip(this)">name</a></font>,<br>
&nbsp; int <font color="#FFFFFF"> <a class="synParam" onclick="showTip(this)">namelen</a></font><br>
	);</font></p></td>
  </tr>
</table>
<h4><font face="Verdana" size="2">Parameters</font></h4>
<dl>
	<dt><font face="Verdana"><i><font size="2">u</font></i></font></dt>
	<dd><font face="Verdana" size="2">[in] Descriptor identifying an unbound 
	socket.</font></dd>
	<dt><font face="Verdana"><i><font size="2">name</font></i></font></dt>
	<dd><font face="Verdana" size="2">[in] Address to assign to the socket from 
	the <u>sockaddr</u> 
	structure.</font></dd>
	<dt><font face="Verdana"><i><font size="2">namelen</font></i></font></dt>
	<dd><font face="Verdana" size="2">[in] Length of the value in the name 
	parameter.</font></dd>
</dl>
<h4><font face="Verdana" size="2">Return Values</font></h4>
<p><font face="Verdana" size="2">If the binding is successful, bind returns 0, 
otherwise it returns UDT::ERROR and the specific error information can be 
retrieved using <a href="error.htm">getlasterror</a>.</font></p>
  <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" id="table2" bordercolordark="#C0C0C0" bordercolorlight="#C0C0C0" width="100%">
    <tr>
      <th align="center" bgcolor="#C0C0C0" width="133">
		<font face="Verdana" size="2">Error Code</font></th>
      <th align="center" bgcolor="#C0C0C0" width="812"><b>
      <font face="Verdana" size="2">Comment</font></b></th>
    </tr>
    <tr>
      <td width="133">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		5001</font></td>
      <td width="812">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		<i>u</i> 
		has already been bound to a certain address.</font></td>
    </tr>
    <tr>
      <td width="133">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		5003</font></td>
      <td width="812">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		the address is either invalid or unavailable.</font></td>
    </tr>
    <tr>
      <td width="133">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		5004</font></td>
      <td width="812">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		<i>u</i> 
		is an invalid UDT socket.</font></td>
    </tr>
    </table>
  <H4><font face="Verdana" size="2">Description</font></H4>
<P><font face="Verdana" size="2">The 
<b>bind</b> method is usually used to assign a UDT socket a local address, 
including the IP version, local IP address, and port number. This is not 
necessary in all cases, except that before a listen call, a socket must be 
bound.</font></P>
<P><font face="Verdana" size="2">If the <b>bind</b> method is not called by applications, the 
socket will be bound to any available address automatically when 
<a href="connect.htm">connect</a> is 
called.</font></P>
<p></p>
<p></p>
<H4><font face="Verdana" size="2">See Also</font></H4>
<P><font face="Verdana" size="2"><b>
<a href="listen.htm">listen</a>, <a href="connect.htm">connect</a>,</b> <b>
<a href="opt.htm">setsockopt</a></b>,
<b><a href="opt.htm">getsockopt</a></b></font></P>

</body>

</html>